            
class RichRemindController 
{

    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only accept POST requests
    static allowedMethods = [save:'POST', update:'POST']

    def stockpool = {}
    def stockpool2 = {}
    def stockpool3 = {}
    def stockCYB = {}
    
    def list = 
    {
    	def flag = params.flag;
        if(!params.max) params.max = 10;
        if(!params.offset) params.offset = 0;
        def nametj = "";
        def richRemindInstanceList = [];
        def totalRow;   
        if(params.nametj)
        	nametj = params.nametj;
        if(nametj && nametj != "")
        {
        	if(params.sort && params.order)
        	{
        		richRemindInstanceList = RichRemind.findAll("from RichRemind where title like '%${nametj}%' and flag='${params.flag}' order by ${params.sort} ${params.order} ", [max:params.max.toInteger(), offset:params.offset.toInteger()]);
        	}else
        	{
        		richRemindInstanceList = RichRemind.findAll("from RichRemind where title like '%${nametj}%' and flag='${params.flag}'  order by ordernum", [max:params.max.toInteger(), offset:params.offset.toInteger()]);
        	}
        	totalRow = RichRemind.executeQuery("select count(*) from RichRemind where title like '%${nametj}%' and flag='${params.flag}'"); 
        	totalRow = totalRow[0];      	
        }else
        {
        	if(params.sort && params.order)
        	{
        		richRemindInstanceList = RichRemind.findAll("from RichRemind where flag='${params.flag}' order by ${params.sort} ${params.order} ", [max:params.max.toInteger(), offset:params.offset.toInteger()]);
        	}else
        	{
        		richRemindInstanceList = RichRemind.findAll("from RichRemind where flag='${params.flag}' order by ordernum", [max:params.max.toInteger(), offset:params.offset.toInteger()]);
        	}
        	totalRow  = RichRemind.executeQuery("select count(*) from RichRemind where flag='${params.flag}'");
        	totalRow = totalRow[0];
        }
        
        return [ richRemindInstanceList:richRemindInstanceList, totalRow:totalRow, nametj:nametj, max:params.max, offset:params.offset, sort:params.sort, order:params.order, flag:flag ]
    }
    

    def show = 
    {
        def richRemindInstance = RichRemind.get( params.id )

        if(!richRemindInstance) 
        {
            flash.message = message(code:'lxh.display.noFindMsg')
            redirect(action:list)
        }
        else { return [ richRemindInstance : richRemindInstance ] }
    }

    def delete = 
    {
        def richRemindInstance = RichRemind.get( params.id )
        if(richRemindInstance) 
        {
            richRemindInstance.delete()
            flash.message = message(code:'lxh.display.deleteMsg')
            redirect(action:list, params:[flag:params.flag])
        }else 
        {
            flash.message = message(code:'lxh.display.noFindMsg')
            redirect(action:list, params:[flag:params.flag])
        }
    }

    def edit = 
    {
        def richRemindInstance = RichRemind.get( params.id )

        if(!richRemindInstance) 
        {
            flash.message = message(code:'lxh.display.noFindMsg')
            redirect(action:list, params:[flag:params.flag])
        }else 
        {
            return [ richRemindInstance : richRemindInstance, flag:params.flag ]
        }
    }

    def update = 
    {
        def richRemindInstance = RichRemind.get( params.id )
        if(richRemindInstance) 
        {
            richRemindInstance.properties = params
            richRemindInstance.lastUpdateDate = new Date();
            if(!richRemindInstance.hasErrors() && richRemindInstance.save()) 
            {
                flash.message = message(code:'lxh.display.updateMsg')
                redirect(action:list, params:[flag:params.flag])
            }else 
            {
                render(view:'edit',model:[richRemindInstance:richRemindInstance,flag:params.flag])
            }
        }else 
        {
            flash.message = message(code:'lxh.display.noFindMsg')
            redirect(action:edit,id:params.id, params:[flag:params.flag])
        }
    }

    def create = 
    {
        def richRemindInstance = new RichRemind()
        richRemindInstance.properties = params
        return ['richRemindInstance':richRemindInstance, flag:params.flag]
    }

    def save = 
    {
        def richRemindInstance = new RichRemind(params)
        richRemindInstance.flag = params.flag;
        richRemindInstance.createDate = new Date();
        richRemindInstance.lastUpdateDate = new Date();
        if(!richRemindInstance.hasErrors() && richRemindInstance.save()) 
        {
            flash.message = message(code:'lxh.display.createMsg')
            redirect(action:list,params:[flag:params.flag])
        }else 
        {
            render(view:'create',model:[richRemindInstance:richRemindInstance,flag:params.flag])
        }
    }
    
    def jijin = {}
    
}